<!---->
<!--  Created by An An on 17/1/16.-->
<!--  Copyright © 2017年 An An. All rights reserved.-->
<!--//*************** ...... SOURCE CODE ...... ***************-->
<!--//***...................................................***-->
<!--//*** https://github.com/AAChartModel/AAChartKit        ***-->
<!--//*** https://github.com/AAChartModel/AAChartKit-Swift  ***-->
<!--//***...................................................***-->
<!--//*************** ...... SOURCE CODE ...... ***************-->

<!--/*-->
<!---->
<!--* --------------------------------------------------------------------------------->
<!--*-->
<!--* ❀❀❀   WARM TIPS!!!   ❀❀❀-->
<!--*-->
<!--* Please contact me on GitHub,if there are any problems encountered in use.-->
<!--* GitHub Issues : https://github.com/AAChartModel/AAChartKit/issues-->
<!--* --------------------------------------------------------------------------------->
<!--* And if you want to contribute for this project, please contact me as well-->
<!--* GitHub        : https://github.com/AAChartModel-->
<!--* StackOverflow : https://stackoverflow.com/users/7842508/codeforu-->
<!--* JianShu       : http://www.jianshu.com/u/f1e6753d4254-->
<!--* SegmentFault  : https://segmentfault.com/u/huanghunbieguan-->
<!--*-->
<!--* --------------------------------------------------------------------------------->
<!---->
<!--*/-->

<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 3.0,user-scalable = no">
            
            <script src="AAHighchartsLib.js">
                </script>
            <script src="AAHighchartsMore.js">
                </script>
<!--                        <script src="AAHighcharts-3d.js">-->
<!--                            </script>-->
            <script src="AAFunnel.js">
                </script>
            <!--    若介意本地js代码体积(250KB左右,工程打包压缩后实际体积远小于此)过大，可换用加载网络js代码 -->
            <!--            <script src="https://img.hcharts.cn/highcharts/highcharts.js">-->
            <!--                </script>-->
            <!--            <script src="https://img.hcharts.cn/highcharts/highcharts-more.js">-->
            <!--                </script>-->
            
            
            <style>
                *{
                    -webkit-user-select: none;
                    user-select: none;
                }
            </style>
            
            </head>
    <body>
        <div id="container" style="width: min-450px; height: 200px; margin: -8px">
        </div>
        <script >
            
            var globalChart;
            
            function loadTheHighChartView (sender,receivedWidth,receivedHeight) {
                var container = document.getElementById('container');//获得元素
                if (receivedWidth != 0) {
                    container.style.width = receivedWidth;//设置宽度
                }
                container.style.height = receivedHeight;//设置高度
                
                var JavaScriptObject = JSON.parse(sender);
                
                if (JavaScriptObject.gradientColorEnabled == true) { //开启图表渐变色功能
                    var colors = JavaScriptObject.colors;
                    JavaScriptObject.colors = Highcharts.map(colors, function (color) {
                                                                    return {
                                                                    linearGradient:  { x1: 0, y1: 0, x2: 0, y2: 1},
                                                                    stops: [
                                                                            [0, color],
                                                                            [1, Highcharts.Color(color).setOpacity(0.6).get('rgba')]
                                                                            ]
                                                                    };
                                                                    });
                }
                
                //Set the 'Reset zoom button' title
                Highcharts.setOptions({
                                      lang: {
                                      resetZoom: JavaScriptObject.zoomResetButtonText//Set 'Reset zoom button' title if title is not set in receivedZoomButtonTitle
                                      }
                                      });
                
                JavaScriptObject.credits = {enabled:false};//去掉表格右下角版权信息
                
                if (JavaScriptObject.plotOptions) {
                    var animation = JavaScriptObject.plotOptions.series.animation;
                    if (animation) {
                        var animationEasingType = animation.easing;
                        JavaScriptObject.plotOptions.series.animation.easing = configureTheChartAnimationEasingType(animationEasingType);
                    }
                }

                globalChart = Highcharts.chart('container', JavaScriptObject );
            }
        
        
        function onlyRefreshTheChartDataWithSeries (receivedSeries) {
            var receivedSeriesElementArr = JSON.parse(receivedSeries);
            
            for (var i = 0; i < receivedSeriesElementArr.length; i++) {
                var receivedSeriesData = receivedSeriesElementArr[i].data;
                // 获取series
                var chartSeries =  globalChart.series[i];
                // 执行只刷新数据的函数
                chartSeries.setData(receivedSeriesData);
            }
        }
        
        function configureTheChartAnimationEasingType (easingType) {
                switch (easingType) {
                case "easeInQuad":
                    return function(pos) {
                        return Math.pow(pos, 2);
                    };
                case "easeOutQuad":
                    return function(pos) {
                        return - (Math.pow((pos - 1), 2) - 1);
                    };
                case "easeInOutQuad":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 2);
                        return - 0.5 * ((pos -= 2) * pos - 2);
                    };
                case "easeInCubic":
                    return function(pos) {
                        return Math.pow(pos, 3);
                    };
                case "easeOutCubic":
                    return function(pos) {
                        return (Math.pow((pos - 1), 3) + 1);
                    };
                case "easeInOutCubic":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 3);
                        return 0.5 * (Math.pow((pos - 2), 3) + 2);
                    };
                case "easeInQuart":
                    return function(pos) {
                        return Math.pow(pos, 4);
                    };
                case "easeOutQuart":
                    return function(pos) {
                        return - (Math.pow((pos - 1), 4) - 1);
                    };
                case "easeInOutQuart":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 4);
                        return - 0.5 * ((pos -= 2) * Math.pow(pos, 3) - 2);
                    };
                case "easeInQuint":
                    return function(pos) {
                        return Math.pow(pos, 5);
                    };
                case "easeOutQuint":
                    return function(pos) {
                        return (Math.pow((pos - 1), 5) + 1);
                    };
                case "easeInOutQuint":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 5);
                        return 0.5 * (Math.pow((pos - 2), 5) + 2);
                    };
                case "easeInSine":
                    return function(pos) {
                        return - Math.cos(pos * (Math.PI / 2)) + 1;
                    };
                case "easeOutSine":
                    return function(pos) {
                        return Math.sin(pos * (Math.PI / 2));
                    };
                case "easeInOutSine":
                    return function(pos) {
                        return ( - 0.5 * (Math.cos(Math.PI * pos) - 1));
                    };
                case "easeInExpo":
                    return function(pos) {
                        return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1));
                    };
                case "easeOutExpo":
                    return function(pos) {
                        return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
                    };
                case "easeInOutExpo":
                    return function(pos) {
                        if (pos === 0) return 0;
                        if (pos === 1) return 1;
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(2, 10 * (pos - 1));
                        return 0.5 * ( - Math.pow(2, -10 * --pos) + 2);
                    };
                case "easeInCirc":
                    return function(pos) {
                        return - (Math.sqrt(1 - (pos * pos)) - 1);
                    };
                case "easeOutCirc":
                    return function(pos) {
                        return Math.sqrt(1 - Math.pow((pos - 1), 2));
                    };
                case "easeInOutCirc":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return - 0.5 * (Math.sqrt(1 - pos * pos) - 1);
                        return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1);
                    };
                case "easeOutBounce":
                    return function(pos) {
                        if ((pos) < (1 / 2.75)) {
                            return (7.5625 * pos * pos);
                        } else if (pos < (2 / 2.75)) {
                            return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
                        } else if (pos < (2.5 / 2.75)) {
                            return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
                        } else {
                            return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
                        }
                    };
                case "easeInBack":
                    return function(pos) {
                        var s = 1.70158;
                        return (pos) * pos * ((s + 1) * pos - s);
                    };
                case "easeOutBack":
                    return function(pos) {
                        var s = 1.70158;
                        return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1;
                    };
                case "easeInOutBack":
                    return function(pos) {
                        var s = 1.70158;
                        if ((pos /= 0.5) < 1) return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));
                        return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
                    };
                case "elastic":
                    return function(pos) {
                        return - 1 * Math.pow(4, -8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1;
                    };
                case "swingFromTo":
                    return function(pos) {
                        var s = 1.70158;
                        return ((pos /= 0.5) < 1) ? 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) : 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
                    };
                case "swingFrom":
                    return function(pos) {
                        var s = 1.70158;
                        return pos * pos * ((s + 1) * pos - s);
                    };
                case "swingTo":
                    return function(pos) {
                        var s = 1.70158;
                        return (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
                    };
                case "bounce":
                    return function(pos) {
                        if (pos < (1 / 2.75)) {
                            return (7.5625 * pos * pos);
                        } else if (pos < (2 / 2.75)) {
                            return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
                        } else if (pos < (2.5 / 2.75)) {
                            return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
                        } else {
                            return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
                        }
                    };
                case "bouncePast":
                    return function(pos) {
                        if (pos < (1 / 2.75)) {
                            return (7.5625 * pos * pos);
                        } else if (pos < (2 / 2.75)) {
                            return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
                        } else if (pos < (2.5 / 2.75)) {
                            return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
                        } else {
                            return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
                        }
                    };
                case "easeFromTo":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 4);
                        return - 0.5 * ((pos -= 2) * Math.pow(pos, 3) - 2);
                    };
                case "easeFrom":
                    return function(pos) {
                        return Math.pow(pos, 4);
                    };
                case "easeTo":
                    return function(pos) {
                        return Math.pow(pos, 0.25);
                    }
                }
            }
            
        //pragma mark -- setter method
        function setTheChartViewContentWidth (receivedWidth) {
            var container = document.getElementById('container');//获得元素
            container.style.width = receivedWidth;//设置宽度
            globalChart.reflow();
        }
        
        function setTheChartViewContentHeight (receivedHeight) {
            var container = document.getElementById('container');//获得元素
            container.style.height = receivedHeight;//设置高度
            globalChart.reflow();
        }
        
        function setChartSeriesHidden (hidden) {
            for (var i = 0; i < globalChart.series.length; i++) {
                var series = globalChart.series[i];
                if (hidden == true) {
                    series.hide();
                } else {
                    series.show();
                }
            }
        }
        
        function showTheSeriesElementContentWithIndex (elementIndex) {
            var series = globalChart.series[elementIndex];
            series.show();
        }
        
        function hideTheSeriesElementContentWithIndex (elementIndex) {
            var series = globalChart.series[elementIndex];
            series.hide();
        }
        
            </script>
    </body>
</html>
